package com.chenjt.netty.six_gPRC.simple;

import com.chenjt.netty.six_gPRC.generateCode.MyRequest;
import com.chenjt.netty.six_gPRC.generateCode.MyResponse;
import com.chenjt.netty.six_gPRC.generateCode.StudentServiceGrpc;
import io.grpc.stub.StreamObserver;

/**
 * 注释：
 *
 * @author chenjt
 * @date 2024/8/16 10:23
 */
public class StudentServiceImpl extends StudentServiceGrpc.StudentServiceImplBase {

    @Override
    public void getRealNameByUsername(MyRequest request, StreamObserver<MyResponse> responseObserver) {
        System.out.println("接收到客户端信息：" + request.getUsername());

        // 返回信息给客户端
        responseObserver.onNext(MyResponse.newBuilder().setRealname("张三").build());
        // 标识方法调用已经结束
        responseObserver.onCompleted();
    }
}
